function [idx]=ecogTime2Sample(ecog,time)
%[idx]=ecogTime2Sample(ecog,time) convert time to index into timeseries
%
% PURPOSE:
% Provide the sample number (index) for a time point in the data time
% series. Rounds to the closest actually available. 
%
% INPUT: 
% ecog:    An ecog structure with fields data, timebase, and sampDur
% time:    The time point in ms (or the unit used in timebae and sampDur)
%
% OUTPUT:
% idx:     The index for the desired time point in the data time series

% 20120105 JR wrote it

idx=round((time-ecog.timebase(1))/ecog.sampDur);